<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">

<title>修改用户</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="description" content="修改用户">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="/sm/pages/css/style.css">
<script type='text/javascript' src='/sm/dwr/interface/managerAjax.js'></script>
<script type='text/javascript' src='/sm/dwr/engine.js'></script>
<script type='text/javascript' src='/sm/pages/js/validator.js'></script>
<script type='text/javascript'>
    function submitForm(){
          var form = document.getElementById("modForm");
          if(isNull(form.loginName.value)){
              alert("请输入登录名称！");
              return false;
          }
          if(isNull(form.userName.value)){
              alert("请输入用户名称！");
              return false;
          }
          if(isNull(form.password.value)){
              alert("请输入登录密码！");
              return false;
          }
          if(isNull(form.repassword.value)){
              alert("请输入确认密码！");
              return false;
          }
          if(form.password.value!="" && form.repassword.value!=""){
              if(form.password.value!=form.repassword.value){
                 alert("登录密码与确认密码不一致！");
                 return false;
              }
          }
          if(isNull(form.role.value)){
              alert("请选择角色！");
              return false;
          }
          if(!isNull(form.phone.value)){
              if(!checkMobile(form.phone.value)){
                 alert("联系电话输入有误！");
                 return false;
              };
          }
          form.submit();
    }
</script>
</head>
<body>
<form id="modForm" action="/sm/controller/user/mod" method="POST">
<input type="hidden" name="id" value="${user.id }"/>
<table>
	<tr>
		<td>登录名</td><td><input type="text" name="loginName" value="${user.loginName}" readonly="readonly"/></td>
	</tr>
	<tr>
		<td>用户名</td><td><input type="text" name="userName" value="${user.userName }" maxlength="50"/></td>
	</tr>
	<tr>
		<td>密码</td><td><input type="password" name="password" value="${user.password}" maxlength="50"/></td>
	</tr>
	<tr>
		<td>重新输入密码</td><td><input type="password" name="repassword" value="${user.password}" maxlength="50"/></td>
	</tr>
	<tr>
		<td>角色</td>
		<td><select name="role">
		<option value="opera" <c:if test="${user.role == 'opera' }">selected = "selected"</c:if>>操作员</option>
		<option value="admin" <c:if test="${user.role == 'admin' }">selected = "selected"</c:if>>管理员</option>
		<option value="user" <c:if test="${user.role == 'user' }">selected = "selected"</c:if>>普通用户</option>
		</select></td>
	</tr>
	<tr>
	    <td>联系电话</td><td><input type="text" name="phone" value="${user.phone}" maxlength="50"/></td>
	</tr>
	<tr>
	    <td>&nbsp;</td>
	    <td><input type="button" value="修改" onclick="submitForm();"/></td>
	</tr>
</table>
</form>
</body>
</html>